# Copyright 2016 PerfKitBenchmarker Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Supported types of operating systems that a VM may host."""

from absl import flags

AMAZONLINUX2 = 'amazonlinux2'
AMAZONLINUX2023 = 'amazonlinux2023'
AMAZON_NEURON = 'amazon_neuron'
CENTOS_STREAM9 = 'centos_stream9'
CLEAR = 'clear'
COS = 'cos'  # stable
COS_DEV = 'cos_dev'
COS125 = 'cos125'
COS121 = 'cos121'
COS117 = 'cos117'
COS113 = 'cos113'
CORE_OS = 'core_os'
DEBIAN11 = 'debian11'
DEBIAN11_BACKPORTS = 'debian11_backports'
DEBIAN12 = 'debian12'
DEBIAN13 = 'debian13'
FEDORA36 = 'fedora36'
FEDORA37 = 'fedora37'
OL8 = 'ol8'
OL9 = 'ol9'
RHEL8 = 'rhel8'
RHEL9 = 'rhel9'
RHEL10 = 'rhel10'
ROCKY_LINUX8 = 'rocky_linux8'
ROCKY_LINUX8_OPTIMIZED = 'rocky_linux8_optimized'
ROCKY_LINUX9 = 'rocky_linux9'
ROCKY_LINUX9_OPTIMIZED = 'rocky_linux9_optimized'
ROCKY_LINUX10 = 'rocky_linux10'
ROCKY_LINUX10_OPTIMIZED = 'rocky_linux10_optimized'
UBUNTU2004 = 'ubuntu2004'
UBUNTU2004_EFA = 'ubuntu2004_efa'
UBUNTU2004_DL = 'ubuntu2004_dl'
DEBIAN12_DL = 'debian12_dl'
AMAZONLINUX2_DL = 'amazonlinux2_dl'
UBUNTU2204 = 'ubuntu2204'
UBUNTU2404 = 'ubuntu2404'
WINDOWS2016_CORE = 'windows2016_core'
WINDOWS2019_CORE = 'windows2019_core'
WINDOWS2022_CORE = 'windows2022_core'
WINDOWS2025_CORE = 'windows2025_core'
WINDOWS2016_DESKTOP = 'windows2016_desktop'
WINDOWS2019_DESKTOP = 'windows2019_desktop'
WINDOWS2022_DESKTOP = 'windows2022_desktop'
WINDOWS2025_DESKTOP = 'windows2025_desktop'
WINDOWS2019_SQLSERVER_2017_STANDARD = (
    'windows2019_desktop_sqlserver_2017_standard'
)
WINDOWS2019_SQLSERVER_2017_ENTERPRISE = (
    'windows2019_desktop_sqlserver_2017_enterprise'
)
WINDOWS2019_SQLSERVER_2019_STANDARD = (
    'windows2019_desktop_sqlserver_2019_standard'
)
WINDOWS2019_SQLSERVER_2019_ENTERPRISE = (
    'windows2019_desktop_sqlserver_2019_enterprise'
)
WINDOWS2022_SQLSERVER_2019_STANDARD = (
    'windows2022_desktop_sqlserver_2019_standard'
)
WINDOWS2022_SQLSERVER_2019_ENTERPRISE = (
    'windows2022_desktop_sqlserver_2019_enterprise'
)
WINDOWS2022_SQLSERVER_2022_STANDARD = (
    'windows2022_desktop_sqlserver_2022_standard'
)
WINDOWS2022_SQLSERVER_2022_ENTERPRISE = (
    'windows2022_desktop_sqlserver_2022_enterprise'
)
WINDOWS2025_SQLSERVER_2019_STANDARD = (
    'windows2025_desktop_sqlserver_2019_standard'
)
WINDOWS2025_SQLSERVER_2019_ENTERPRISE = (
    'windows2025_desktop_sqlserver_2019_enterprise'
)
WINDOWS2025_SQLSERVER_2022_STANDARD = (
    'windows2025_desktop_sqlserver_2022_standard'
)
WINDOWS2025_SQLSERVER_2022_ENTERPRISE = (
    'windows2025_desktop_sqlserver_2022_enterprise'
)

# Base-only OS types
DEBIAN = 'debian'
RED_HAT = 'redhat'
WINDOWS = 'windows'

# DO NOT USE FOO_OS_TYPES! Prefer vm.BASE_OS_TYPE == FOO
# Only use FOO_OS_TYPES when a vm object is not available.

# These operating systems have SSH like other Linux OSes, but no package manager
# to run Linux benchmarks without Docker.
# Because they cannot install packages, they only support VM life cycle
# benchmarks like cluster_boot.
CONTAINER_OS_TYPES = [
    CORE_OS,
    COS,
    COS125,
    COS121,
    COS117,
    COS113,
    COS_DEV,
]

DEBIAN_OS_TYPES = [
    DEBIAN11,
    DEBIAN11_BACKPORTS,
    DEBIAN12,
    DEBIAN13,
    UBUNTU2004,
    UBUNTU2004_EFA,
    UBUNTU2004_DL,
    UBUNTU2204,
    UBUNTU2404,
]

# All OS types that use yum or dnf for package management.
# (In this context, "Red Hat" just means derived from Red Hat Linux).
RED_HAT_OS_TYPES = [
    AMAZONLINUX2,
    AMAZONLINUX2_DL,
    AMAZONLINUX2023,
    AMAZON_NEURON,
    CENTOS_STREAM9,
    FEDORA36,
    FEDORA37,
    OL8,
    OL9,
    RHEL8,
    RHEL9,
    RHEL10,
    ROCKY_LINUX8,
    ROCKY_LINUX8_OPTIMIZED,
    ROCKY_LINUX9,
    ROCKY_LINUX9_OPTIMIZED,
    ROCKY_LINUX10,
    ROCKY_LINUX10_OPTIMIZED,
]

LINUX_OS_TYPES = (
    [CLEAR] + CONTAINER_OS_TYPES + DEBIAN_OS_TYPES + RED_HAT_OS_TYPES
)

WINDOWS_CORE_OS_TYPES = [
    WINDOWS2016_CORE,
    WINDOWS2019_CORE,
    WINDOWS2022_CORE,
    WINDOWS2025_CORE,
]

WINDOWS_DESKOP_OS_TYPES = [
    WINDOWS2016_DESKTOP,
    WINDOWS2019_DESKTOP,
    WINDOWS2022_DESKTOP,
    WINDOWS2025_DESKTOP,
]

WINDOWS_SQLSERVER_OS_TYPES = [
    WINDOWS2019_SQLSERVER_2017_STANDARD,
    WINDOWS2019_SQLSERVER_2017_ENTERPRISE,
    WINDOWS2019_SQLSERVER_2019_STANDARD,
    WINDOWS2019_SQLSERVER_2019_ENTERPRISE,
    WINDOWS2022_SQLSERVER_2019_STANDARD,
    WINDOWS2022_SQLSERVER_2019_ENTERPRISE,
    WINDOWS2022_SQLSERVER_2022_STANDARD,
    WINDOWS2022_SQLSERVER_2022_ENTERPRISE,
    WINDOWS2025_SQLSERVER_2019_STANDARD,
    WINDOWS2025_SQLSERVER_2019_ENTERPRISE,
    WINDOWS2025_SQLSERVER_2022_STANDARD,
    WINDOWS2025_SQLSERVER_2022_ENTERPRISE,
]

WINDOWS_OS_TYPES = (
    WINDOWS_CORE_OS_TYPES + WINDOWS_DESKOP_OS_TYPES + WINDOWS_SQLSERVER_OS_TYPES
)

ALL = LINUX_OS_TYPES + WINDOWS_OS_TYPES
BASE_OS_TYPES = [CLEAR, CORE_OS, DEBIAN, RED_HAT, WINDOWS]

# May change from time to time.
DEFAULT = UBUNTU2404

flags.DEFINE_enum('os_type', DEFAULT, ALL, "The VM's OS type.")
